#ifndef _LB_BATT_H_
#define _LB_BATT_H_

#include <stdint.h>


#define ADC_INPUT_CHANNEL  ADC_CONFIG_PSEL_AnalogInput2
#define ADC_REF_VOLTAGE_IN_MILLIVOLTS        1200                                     /**< Reference voltage (in  milli volts) used by ADC while doing conversion. */
#define ADC_PRE_SCALING_COMPENSATION         1                                         /**< The ADC is configured to use VDD with no prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.*/
#define ADC_HW_PRE_SCALING_COMPENSATION      4

#define BATTERY_ADC_RESOLUTION  (ADC_CONFIG_RES_10bit)
#define BATTERY_ADC_DIV         (1023)

#define MIN_BAT_MV (3600)
#define CHARGER_CHECK_INTERVAL_MS   (APP_TIMER_TICKS(1000, APP_TIMER_PRESCALER))
#define BATT_CHECK_INTERVAL   (APP_TIMER_TICKS(1000 * 2, APP_TIMER_PRESCALER))

#define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)\
        ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS)\
        * ADC_PRE_SCALING_COMPENSATION * ADC_HW_PRE_SCALING_COMPENSATION)/ BATTERY_ADC_DIV)

typedef enum
{
    CHARGING,
    CHARGE_COMPLETE,
    NO_CHARGER,
}charger_status;

charger_status check_charger_status(void);
void check_charger(void);

void battery_start(void);
void battery_measure_init(void);
void battery_measure_timer_start(uint32_t interval);
uint8_t get_battery_power_percentage(void);
void init_bat_service(void);



#endif
